﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.Mobile.Configuration;

namespace ConfigurationGettingStarted
{
    class AppSettingCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new Setting();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            Setting e = (Setting)element;

            return e.Key;
        }

        public Setting GetMenuItem(int id)
        {
            return (Setting)BaseGet(id);
        }
    }

    class Setting : ConfigurationElement
    {
        private const string AttributeKey = "key";
        private const string AttributeValue = "value";

        [ConfigurationProperty(AttributeKey)]
        public string Key
        {
            get { return (string)this[AttributeKey]; }
            set { this[AttributeKey] = value; }
        }

        [ConfigurationProperty(AttributeValue)]
        public string Value
        {
            get { return (string)this[AttributeValue]; }
            set { this[AttributeValue] = value; }
        }
    }
}
